package hu.issue.framework.web.tag;

import hu.issue.framework.web.Constants;
import hu.issue.framework.web.validation.ErrorMessages;

import java.io.PrintWriter;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;

public class ErrorsTag extends TagSupport {

	@Override
	public int doEndTag() throws JspException {
		final ErrorMessages messages = (ErrorMessages) this.pageContext.getAttribute(Constants.FORM_ERROR, PageContext.REQUEST_SCOPE);
		ErrorRenderer.render(messages, new PrintWriter(this.pageContext.getOut()));
		return EVAL_PAGE;
	}
}
